var ManagementISconnect = function(){
	var thiz=this;
	
	var searchID = new Ext.form.TextField({
		fieldLabel : '客户编号',
		width : 150
	});
	var searchName = new Ext.form.TextField({
		fieldLabel : '客户名称',
		width : 150
	});
	
		var searchComplateEndDate = new Ext.form.DateField( {
		fieldLabel : '至',
		format : 'Y-m-d',
		width : 150
	});
		var searchComplateDate = new Ext.form.DateField( {
		fieldLabel : '联系时间',
		format : 'Y-m-d',
		width : 150
	});
	var btn_search = new Ext.Button({
		text : '查询',
		iconCls: 'icon-search',
		handler: function (){contectStore.load();}
	});
	
	var contectStore = new Ext.data.JsonStore(
			{
				url : '../contect/searchContect.form?timesnap=' + new Date().getTime(),
				root : 'result',
				fields : [ 'id','CustomerName','ContectID', 'ContectDepart', 'ContectGroup','ContectPerson', 'projectTopic',
						   'projectNewlast', 'projectDangerous','projectContectDate', 'projectBus',
						   'BossAdvice','DepartmentAdvice'],
				listeners : {
					scope : this,
					beforeload : function(thiz) {
						thiz.baseParams = {
							customerID : searchID.getValue(),
							customerName:searchName.getValue(),
							startContectDate:searchComplateDate.getValue()? searchComplateDate.getValue().format('Y-m-d') : '',
							endContectDate:searchComplateEndDate.getValue()?searchComplateEndDate.getValue().format('Y-m-d'):'',
							SaleStage:0
							};
					}
				}
			});
	
	
	var xg = Ext.grid
	var sm = new xg.CheckboxSelectionModel();
	var contectGrid = new Ext.grid.GridPanel({
	sm: sm,
		width : 900,
		height : 160,
		store : contectStore,
		columns : [sm,
		
				   {header:'客户名称',width: 100,dataIndex:'CustomerName'},
				   {header:'联系日期',width: 100,dataIndex:'projectContectDate'},
				   {header:'所属部门',width: 100,dataIndex:'ContectDepart'},
				   {header:'所属人',width: 100,dataIndex:'ContectPerson'},
		           {header:'联系主题',width: 100,dataIndex:'projectTopic'},
				   {header:'最新进展',width: 150,dataIndex:'projectNewlast'},
				   {header:'困难及难点',width: 150,dataIndex:'projectDangerous'},
		           {header:'部门意见',width: 150,dataIndex:'DepartmentAdvice'},
		           {header:'总经理意见',width: 250,dataIndex:'BossAdvice'}
		           ],
		bbar:new Ext.PagingToolbar({
		  		   pageSize: 5,
		           store: contectStore,
		           displayInfo: true,
		           displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
		           emptyMsg: "没有记录..."
		          })
	});
	
	
	var DepartmentAdvice = new Ext.form.TextArea({
		fieldLabel : '部门经理意见',
		width : 800
	});
	var BossAdvice = new Ext.form.TextArea({
		fieldLabel : '总经理意见',
		width : 800
	});
	
	
	var updateContect = new Ext.data.Connection({
		waitTitle : '系统提示',
		waitMsg : '数据提交中，请稍候...',
		url:'../contect/updateContect.form?timesnap=' + new Date().getTime(),
		method:'post'
	});
	
//	var userStore = new Ext.data.JsonStore({
//				url : '../contect/getUserInfo.form?status=11&timesnap=' + new Date()
//						.getTime(),
//				root : 'result',
//				fields : [ 'user'],
//				listeners : {
//					scope : this,
//					beforeload : function(thiz) {
//						thiz.baseParams = {
//						
//						};
//					}
//				}
//			});
	
	
	
	this.Managementconnect = new Ext.form.FormPanel({
		frame : true,
		width : 950,
		fileUpload: true, 
		labelWidth : 85,
		buttons : [
		           {text:'保存',iconCls: 'icon-accept',scope:this,handler:function(){
			           var scope=this;
							Utils.confirm2({
								msg:"是否保存？",
								width:220,
								fn:function(){
										var count=contectGrid.getSelectionModel().getSelections();
										var ids="";
										if(count<=0){//这里 的逻辑 按照网格里的数据判断的
											alert("请选择数据");
											return false;
											}
										for(var i=0 ;i<count.length;i++){
											var data = count[i].data['ContectID'];
											ids+=count[i].data['ContectID']+',';
											}
									scope.Managementconnect.getForm().submit({
											waitTitle : '系统提示',
											waitMsg : '数据提交中，请稍候...',
											url:'../contect/updateContect.form?timesnap=' + new Date().getTime()+'&ids='+ids,
											method:'post',
											params:{
													BossAdvice:BossAdvice.getValue(),
													DepartmentAdvice:DepartmentAdvice.getValue()
												},
											success:function(data){
												Utils.info("操作成功","系统提示");	
												contectStore.load();
												}
		           							});
		           					}
		           				});
		           			}
		           		},
		           		{text:'重置',iconCls: 'icon-return'}
		           ],
		items : [{layout:'column',defaults:{layout:'form'},
			      items:[ {columnWidth:0.3,items:[searchID]},
			      		 {columnWidth:0.3,items:[searchName]},
			             {columnWidth:0.3,items:[searchComplateDate]},
			             {columnWidth:0.3,items:[searchComplateEndDate]},
			             {columnWidth:0.1,items:[btn_search]}]
				},contectGrid,{layout:'column',defaults:{layout:'form'},
				  items:[ {columnWidth:3,items:[DepartmentAdvice]},    
			 			  {columnWidth:3,items:[BossAdvice]}] }
				],		
		listeners: {
		    		render: {fn:function(){ 
						
						
						
						}
							}
					}	
		});
};